package logic

import (
	"context"
	"houses_srv/models"

	"houses_srv/houses"
	"houses_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddLikeHouseLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddLikeHouseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLikeHouseLogic {
	return &AddLikeHouseLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AddLikeHouseLogic) AddLikeHouse(in *houses.AddLikeHouseRequest) (*houses.AddLikeHouseResponse, error) {
	// todo: add your logic here and delete this line

	var like models.LikeHouse

	like.UserId = int(in.UserId)
	like.HouseId = int(in.HouseId)

	err := like.AddLike()
	if err != nil {
		return nil, err
	}

	return &houses.AddLikeHouseResponse{LikeHouseId: int64(like.ID)}, nil
}
